package cn.edu.lit.jsjxy.CourseExample.chapter3;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import cn.edu.lit.jsjxy.CourseExample.R;

public class ThirdActivity extends Activity implements View.OnClickListener
{

    TextView tvThird;
    Button btnOk;

    String username;


    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_third);

        btnOk = findViewById(R.id.btnOK);
        btnOk.setOnClickListener(this);

        tvThird = findViewById(R.id.tvThird);

        username = getIntent().getStringExtra("username");

        tvThird.setText(username);

    }

    @Override
    public void onClick(View view)
    {
        username = username.toUpperCase();

        Intent intent = new Intent();
        intent.putExtra("username", username);

        setResult(RESULT_OK, intent);
        finish();
    }

    @Override
    public void onBackPressed()
    {
        super.onBackPressed();

        username = username.toUpperCase();

        Intent intent = new Intent();
        intent.putExtra("username", username);

        setResult(RESULT_OK, intent);
        finish();


    }
}
